package cn.mystylefree.config;

import cn.mystylefree.domain.PersonProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @program custom-spring-boot-start
 * @description:
 * @author: lee
 * @create: 2022/06/10 09:06
 */
@Configuration
//当类路径classpath下有指定当类   (PersonProperties)  的情况下进行自动配置
@ConditionalOnClass(PersonProperties.class)
public class MyAutoConfiguration {
    static {
        System.out.println("MyAutoConfiguration init ...");
    }
    @Bean
    public PersonProperties personProperties(){
        return new PersonProperties();
    }
//    @Autowired
//    private SimpleBean simpleBean;
//
//    /**
//     * 加入 @ConditionalOnClass(SimpleBean.class) 后
//     * 防止SimpleBean 不存在报错
//     */
//    public void test(){
//        simpleBean.getId();
//    }

}
